/**
 * Created by leo on 2017/2/28.
 */

import { Injectable } from  '@angular/core';
import { Http, Response, RequestOptions, Headers, URLSearchParams } from '@angular/http';

import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';

@Injectable()
export class HttpService {
  constructor(
    private http:Http
  ){}

  get(url:string){
    let headers = new Headers({ 'Accept': 'application/vnd.kid-center-1.0+json' });
    let options = new RequestOptions({ headers: headers,withCredentials:true });
    return this.http.get(url,options)
      .map(res => {
        return res.json();
      });
  }

  post(url:string,params:any){
    let headers = new Headers({ 'Accept': 'application/vnd.kid-center-1.0+json' });
    let options = new RequestOptions({ headers: headers,withCredentials:true });
    return this.http.post(url,params,options)
      .map(res => {
        return res.json();
      });
  }

}
